package com.xu.t1.controller;

import com.xu.t1.mapper.UserMapper;
import com.xu.t1.model.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 负责查询用户信息的控制层接口类
 *
 * @author xu
 *
 */


@RestController
@RequestMapping("/api/users")
public class UserController {

    private final UserMapper userMapper;

    public UserController(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    // 模糊搜索用户接口
    @GetMapping("/search")
    public List<User> searchUsers(@RequestParam("keyword") String keyword) {
        return userMapper.findUsersByKeyword(keyword);
    }
}